<?php require('../Connections/locale.php'); 
include("./fusioncharts/FusionCharts.php");
?>
<?php
$colname_dati_report = "-1";
if (isset($_GET['id_report'])) {
  $colname_dati_report = (get_magic_quotes_gpc()) ? $_GET['id_report'] : addslashes($_GET['id_report']);
}
mysql_select_db($database_locale, $locale);
$query_dati_report = sprintf("SELECT * FROM reports WHERE id_report = %s", $colname_dati_report);
$dati_report = mysql_query($query_dati_report, $locale) or die(mysql_error());
$row_dati_report = mysql_fetch_assoc($dati_report);
$totalRows_dati_report = mysql_num_rows($dati_report);
$titolo = $row_dati_report['nome'];
$strQuery = $row_dati_report['codice'];
	
	
if (isset($_POST['grafico'])) {
	$tipo_grafico = $_POST['grafico'];
} else {
	$tipo_grafico = "FCF_Column3D";
}
	
?>
<HTML>
   <HEAD>
      <TITLE><?php echo $titolo ?></TITLE>
      <SCRIPT LANGUAGE="Javascript" SRC="../jscripts/FusionCharts.js"></SCRIPT>
      <link href="../style.css" rel="stylesheet" type="text/css">
   </HEAD>
   <BODY>
   <CENTER>
   <p>
     <?php   

	




   $strXML = "<graph caption='".$titolo."' decimalPrecision='0' showNames='1' pieSliceDepth='30' formatNumberScale='0'>";


   //Fetch all factory records
  // $strQuery = "select nome_citta as Comune,count(id_abbonato) as 'Numero Abbonamenti' from abbonati,citta where abbonati.id_citta = citta.id_citta  group by nome_citta ORDER BY 'Numero Abbonamenti' DESC";

  //mysql_select_db($database_locale, $locale);
  $result = mysql_query($strQuery, $locale) or die(mysql_error());


   //$result = mysql_query($strQuery) or die(mysql_error());

   //Iterate through each factory
   if ($result) {
      while($ors = mysql_fetch_array($result)) {

         $strXML .= "<set name='" . $ors[0] . "' value='" . $ors[1] . "' />";
         //free the resultset
      }
   }
   //mysql_close($link);

   //Finally, close <graph> element
   $strXML .= "</graph>";

   //Create the chart - Pie 3D Chart with data from $strXML
   echo renderChart("./fusioncharts/Charts/".$tipo_grafico.".swf", "", $strXML, "grafico", 600, 400);
?>
   </p>
   <form name="form1" method="post" action="">
     <label>Tipologia Grafico
     <select name="grafico">
       <option value="FCF_Area2D">Area 2D</option>
	   <option value="FCF_Bar2D">Barre 2D</option>
	   <option value="FCF_Column2D">Colonne 2D</option>
	   <option value="FCF_Column3D">Colonne 3D</option>
	   <option value="FCF_Pie2D">Torta 2D</option>
	   <option value="FCF_Pie3D">Torta 3D</option>
	   <option value="FCF_Line">Linea</option>

     </select>
     </label>
	 <input name="" value=Aggiorna type="Submit">
   </form>
   
   <p>&nbsp; </p>
   </BODY>
</HTML>
<?php
mysql_free_result($dati_report);
?>